local zhaxiang = fk.CreateSkill {
  name = "reminiscence__zhaxiang",
}

local zhaxiang_mark = "@reminiscence__zhaxiang-phase"

Fk:loadTranslationTable{
  ["reminiscence__zhaxiang"] = "诈降",
  [":reminiscence__zhaxiang"] = "出牌阶段限一次，你可以视为使用一张【火攻】。若造成伤害，你摸三张牌，于本阶段可以多使用一张【杀】。",

  ["$reminiscence__zhaxiang1"] = "诈降之术，因势利导。",
  ["$reminiscence__zhaxiang2"] = "东风已起，点火，冲啊！",

  [zhaxiang_mark] = "诈降",
}

zhaxiang:addEffect("viewas", {
  anim_type = "offensive",
  card_filter = Util.FalseFunc,
  view_as = function (self, player, cards)
    local fire_attack = Fk:cloneCard("fire_attack")
    fire_attack.skillName = zhaxiang.name
    return fire_attack
  end,
  enabled_at_play = function (self, player)
    return player.phase == Player.Play
    and player:usedSkillTimes(zhaxiang.name) == 0
  end,
  after_use = function (self, player, use)
    local room = player.room
    local damage_events = room.logic:getActualDamageEvents(1, function (e)
      if e.data.card then
        return e.data.card == use.card
      end
      return false
    end, Player.HistoryPhase)
    if #damage_events > 0 then
      player:drawCards(3, zhaxiang.name)
      room:addPlayerMark(player, zhaxiang_mark)
    end
  end,
})

zhaxiang:addEffect("targetmod", {
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase
    and player.phase == Player.Play then
      return player:getMark(zhaxiang_mark)
    end
  end,
})

return zhaxiang
